home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / tcl / tcl70b2.lha / tcl7.0b2 / tests / pid.test < prev    next >
Text File  |  1993-05-15  |  2KB  |  59 lines

  1. # Commands covered:  pid
  2. #
  3. # This file contains a collection of tests for one or more of the Tcl
  4. # built-in commands.  Sourcing this file into Tcl runs the tests and
  5. # generates output for errors.  No output means no errors were found.
  6. #
  7. # Copyright (c) 1991-1993 The Regents of the University of California.
  8. # All rights reserved.
  9. #
  10. # Permission is hereby granted, without written agreement and without
  11. # license or royalty fees, to use, copy, modify, and distribute this
  12. # software and its documentation for any purpose, provided that the
  13. # above copyright notice and the following two paragraphs appear in
  14. # all copies of this software.
  15. #
  16. # IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
  17. # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  18. # OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  19. # CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20. #
  21. # THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  22. # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  23. # AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  24. # ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  25. # PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  26. #
  27. # $Header: /user6/ouster/tcl/tests/RCS/pid.test,v 1.1 93/05/15 16:06:39 ouster Exp $ (Berkeley)
  28.  
  29. if {[string compare test [info procs test]] == 1} then {source defs}
  30.  
  31. catch {exec rm -f test1}
  32.  
  33. test open-1.1 {pid command} {
  34.     regexp {^[0-9]+$} [pid]
  35. } 1
  36. test open-1.2 {pid command} {
  37.     set f [open {| echo foo | cat > /dev/null} w]
  38.     set pids [pid $f]
  39.     close $f
  40.     list [llength $pids] [regexp {^[0-9]+$} [lindex $pids 0]] \
  41.         [regexp {^[0-9]+$} [lindex $pids 1]] \
  42.         [expr {[lindex $pids 0] == [lindex $pids 1]}]
  43. } {2 1 1 0}
  44. test open-1.3 {pid command} {
  45.     set f [open test1 w]
  46.     set pids [pid $f]
  47.     close $f
  48.     set pids
  49. } {}
  50. test open-1.4 {pid command} {
  51.     list [catch {pid a b} msg] $msg
  52. } {1 {wrong # args: should be "pid ?fileId?"}}
  53. test open-1.5 {pid command} {
  54.     list [catch {pid gorp} msg] $msg
  55. } {1 {bad file identifier "gorp"}}
  56.  
  57. catch {exec rm -f test1}
  58. concat {}
  59.